package graphiterator;

import java.util.Random;


/**
 * @author Jeremy Mikkola
 */
public class Main {

    public static void main(String[] args) {

        int keep = 20;

        // Start the population
        Population pa = new Population(keep, Math.pow(10, 10));
        Population pb = new Population(keep, Math.pow(10, 10));
        //Graph g1 = new Graph("110000100101110101011110101011101001000011110000100101110101011110101011101001000011100001001011101010111101010111010010000110000100101110101011110101011101001000110000100101110101011110101011101001001100001001011101010111101010111010010110000100101110101011110101011101001110000100101110101011110101011101001100001001011101010111101010111010110000100101110101011110101011101110000100101110101011110101011101100001001011101010111101010111110000100101110101011110101011110000100101110101011110101011100001001011101010111101010110000100101110101011110101110000100101110101011110101100001001011101010111101110000100101110101011110110000100101110101011111100001001011101010111110000100101110101011110000100101110101011100001001011101010110000100101110101110000100101110101100001001011101110000100101110110000100101111100001001011110000100101110000100101100001001110000100110000101100001110000110001100110111", 43);
        Graph g1 = new Graph(new Random(), 43, true);

        System.out.println("Starting point: " + g1.getRank());

        // Insert the 1-bit modifications of g1
        for (int i = 0; i < 903; i++) {
            Graph g2 = Graph.mutate(g1, i);
            pa.insert(g2);
        }

        System.out.println("Modification cycle");
        // Cycle of one modification each time
        for (int x = 0; x < 20; x++) {
            Graph[] gLst = pa.getPopulation();
            for ( Graph g2 : gLst ) {
                if (g2 == null) continue;
                for ( int j = 0; j < 903; j++ ) {
                    Graph g3 = Graph.mutate(g2, j);
                    pb.insert(g3);
                }
            }

            System.out.println("Iteration: " + x
                    + " Current best: " + pb.getFirst().getRank() + " Cliques");
            System.out.println(pb.getFirst());

            pa = pb;
            pb = new Population(keep, Math.pow(10, 10));

        }
    }

}
